<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div>
	<div class="searchbox">
		<span>Search the Pitches</span><br/>
		<input id="pitchSearchTextInput" type="text" class="searchinput" value="${ searchWords }">
		<input id="pitchSearchButton" type="button" value="Search" class="button searchbutton">
		<input id="studentFlag" type="hidden" value=${ user.student } />
		<input id="currentPageIndex" type="hidden" value=${ currentIndex } />
		<input id="currentSearchWords" type="hidden" value="${ searchWords }" />
	</div>
	<div class="filterbox">
		<span>Sort by</span>
		<select class="selectinput">
			<option value="">Most Recent</option>
		</select>
		<span>Show</span>
		<input id="countInput" type="hidden" value=${ count } />
		<input id="pageInput" type="hidden" value=${ page } />
		<select id="countSelectInput" class="selectinput">
			<c:choose>
				<c:when test="${ count == 20 }">
					<option value="10">10</option>
					<option selected value="20">20</option>
					<option value="50">50</option>
				</c:when>
				<c:when test="${ count == 50 }">
					<option value="10">10</option>
					<option value="20">20</option>
					<option selected value="50">50</option>
				</c:when>
				<c:otherwise>
					<option selected value="10">10</option>
					<option value="20">20</option>
					<option value="50">50</option>
				</c:otherwise>
			</c:choose>
		</select>
		<input id="filterButton" type="button" value="Filter" class="button" />
	</div>
	<div>
		<table>
			<c:forEach var="pitch" items="${ pitches }">
			<tr>
				<td class="overview">
					<div>
						<a href="pitch?pitchId=${ pitch.pitchId }"><span class="title"><c:out value="${ pitch.companyName }" /></span>(<c:out value="${ pitch.companyTicker }" />)-<c:out value="${ pitch.recommendation }" /></a><br />
						<c:choose>
						<c:when test="${ pitch.authorAvailable }">
						<span class="date">Posted on <c:out value="${ pitch.date }" /> by <a href="profile?email=${ pitch.authorEmail }"><c:out value="${ pitch.authorFullName }" /></a></span><br />
						</c:when>
						<c:otherwise>
						<span class="date">Posted on <c:out value="${ pitch.date }" /> by <c:out value="${ pitch.authorFullName }" /></span><br />
						</c:otherwise>
						</c:choose>
						<span class="overviewcontent"><c:out value="${ pitch.description }" /></span>
					</div>
				</td>
				<td class="comments">
					<div>
						<c:out value="${ pitch.commentCount }" />
					</div>
				</td>
			</tr>
			</c:forEach>
		</table>
	</div>
	<c:if test="${ needPaging }">
	<c:choose>
		<c:when test="${ user.student }">
		<div class="paging">
			<c:if test="${ needPrevious }">
			<a href="studentHome?searchWords=${ searchWords }&page=${ previousIndex }&count=${ count }">Previous</a>
			&nbsp;
			</c:if>
			<c:forEach var="paging" items="${ pagings }">
				<a href="studentHome?searchWords=${ searchWords }&page=${ paging.index }&count=${ count }">${ paging.index }</a>
				&nbsp;
			</c:forEach>
			<c:if test="${ needNext }">
			<a href="studentHome?searchWords=${ searchWords }&page=${ nextIndex }&count=${ count }">Next</a>
			</c:if>
		</div>
		</c:when>
		<c:otherwise>
		<div class="paging">
			<c:if test="${ needPrevious }">
			<a href="hfHome?searchWords=${ searchWords }&page=${ previousIndex }&count=${ count }">Previous</a>
			&nbsp;
			</c:if>
			<c:forEach var="paging" items="${ pagings }">
				<a href="hfHome?searchWords=${ searchWords }&page=${ paging.index }&count=${ count }">${ paging.index }</a>
				&nbsp;
			</c:forEach>
			<c:if test="${ needNext }">
			<a href="hfHome?searchWords=${ searchWords }&page=${ nextIndex }&count=${ count }">Next</a>
			</c:if>
		</div>
		</c:otherwise>
	</c:choose>
	</c:if>
</div>